<template>
    <div style="background: #f7f8fa ">
        <we-nav-bar></we-nav-bar>
        <p class="comTitle">基本信息</p>
        <div >
            <van-row>
                <van-col span="24">
                    <van-cell-group>
                        <van-cell title="费别" :value="dataList.InsuTypeDesc"/>
                        <van-cell title="总金额" :value="dataList.AmtSum+'元'"/>
                    </van-cell-group>
                </van-col>
            </van-row>
        </div>
        <div>
            <van-row>
                <van-col span="24">
                    <p class="comTitle">单据详情</p>
                    <div v-for="val1 in dataList.GroupItems.GroupItem" :key="val1.GroupID">
                        <van-cell-group class="cell-g">
                            <van-cell title="处方名称" :value="val1.GroupName"/>
                            <van-cell title="处方类型" :value="val1.GroupDesc"/>
                            <van-cell title="处方金额" :value="val1.GroupAmt+'元'"/>
                        </van-cell-group>
                        <van-collapse v-model="activeNames">
                            <van-collapse-item v-for="val2 in val1.SubItems.Item" title="明细" name="1" :key="val2.ItemNo">
                                <div>小项名称 : {{val2.ItemName}}</div>
                                <div>单价 : {{val2.Price}}元</div>
                                <div>数量 : {{val2.Qty}}</div>
                                <div>单位 : {{val2.Unit}}</div>
                                <div>小项总额 : {{val2.ItemAmt}}元</div>
                            </van-collapse-item>
                        </van-collapse>
                    </div>
                </van-col>
            </van-row>
        </div>
    </div>
</template>

<script>
    export default {
        name: "zjzfinfo",
        data(){
            return {
                url:'/app/wechat/Zjzf/',
                activeNames:['1'],
                dataList:[]
            }
        },
        mounted() {
            if(this.$route.query.AdmRowID){
                this.getList(this.$route.query.AdmRowID)
            }
        },
        methods:{
            //获取处方明细
            getList(AdmRowID) {
                this.axios.post(this.url + 'lists/mid/2.html',{type:2,AdmRowID:AdmRowID}).then(({data}) => {
                    if(data.ResultCode==='0' && data.GroupItems!==undefined){
                        this.dataList = data
                        if(data.GroupItems.GroupItem[0]===undefined){
                            this.dataList.GroupItems.GroupItem = [data.GroupItems.GroupItem];

                            if(data.GroupItems.GroupItem[0].SubItems.Item[0]===undefined){
                                this.dataList.GroupItems.GroupItem[0].SubItems.Item = [data.GroupItems.GroupItem[0].SubItems.Item]
                            }
                        }else{
                            for (let i=0,len=data.GroupItems.GroupItem.length;i<len;i++){
                                if(data.GroupItems.GroupItem[i].SubItems.Item[0]===undefined){
                                    this.dataList.GroupItems.GroupItem[i].SubItems.Item = [data.GroupItems.GroupItem[i].SubItems.Item]
                                }
                            }
                        }
                    }
                })
            },
        }
    }
</script>

<style scoped>
    .cell-g{
        margin-top: 1rem;
    }
    .comTitle{
        height:6vh;
        font-size: 1rem;
        line-height: 6vh;
        padding:0 0.1rem;
        border-bottom: 1px solid #eee;
        color:#aaa;
    }

</style>